﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;

public class BuildResources:MonoBehaviour {

    [MenuItem("Export/WindowsResources")]
    public static void BulidWindows() {
        string dir = "Assets/AssetBundels";
        //判断文件夹是否存在
        if (Directory.Exists(dir) == false)
        {
            //创建文件夹
            Directory.CreateDirectory(dir);
        }
        else {
            Directory.Delete(dir, true);
            //创建文件夹
            Directory.CreateDirectory(dir);
        }
        BuildPipeline.BuildAssetBundles(dir, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);
        //BuildPipeline.BuildAssetBundles("Assets/StreamingAssets",BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows);
        AssetDatabase.Refresh();
    }

    [MenuItem("Export/AndroidResources")]
    public static void BulidAndroid() {
        string dir = "Assets/AssetBundels";
        //判断文件夹是否存在
        if (Directory.Exists(dir) == false)
        {
            //创建文件夹
            Directory.CreateDirectory(dir);
        }
        else {
            Directory.Delete(dir, true);
            //创建文件夹
            Directory.CreateDirectory(dir);
        }
        BuildPipeline.BuildAssetBundles(dir, BuildAssetBundleOptions.None, BuildTarget.Android);
        AssetDatabase.Refresh();
    }

}
